<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>比较两个数大小</title>
</head>

<body>
    <input type="text" id="num1" placeholder="请输入第一个数">
    <input type="text" id="num2" placeholder="请输入第二个数">
    <button onclick="compare()">比较大小</button>
    <div id="result"></div>
    <script>
        function compare() {
            var num1 = parseFloat(document.getElementById('num1').value);
            var num2 = parseFloat(document.getElementById('num2').value);
            var resultDiv = document.getElementById('result');
            if (num1 > num2) {
                resultDiv.innerHTML = num1 + " 大于 " + num2;
            } else if (num1 < num2) {
                resultDiv.innerHTML = num1 + " 小于 " + num2;
            } else {
                resultDiv.innerHTML = num1 + " 等于 " + num2;
            }
        }
    </script>
</body>

</html>